/**
 * @author sjw
 * @className Test
 * @date 2021/12/20 17:25
 * @description: TODO
 */
public class Test {
    public static void main(String[] args) {
        A a1=new A(1,"a1");
        A a2=new A(1,"a2");

        System.out.println(a1==a2);
        System.out.println(a1.equals(a2));

    }

    static class A{
        private int id;
        private String name;

        public A(int id, String name){
            this.id=id;
            this.name=name;
        }

        @Override
        public boolean equals(Object obj) {
            if(obj==null)return false;
            else  return this.hashCode()==obj.hashCode();
//            return super.equals(obj);
        }

        @Override
        public int hashCode() {
            return this.id;
        }
    }
}
